//
//  CartViewCell.m
//  AmazingShopping
//
//  Created by Tan on 5/16/13.
//  Copyright (c) 2013 Tan Hoang. All rights reserved.
//

#import "CartViewCell.h"

@implementation CartViewCell

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        // Initialization code
    }
    return self;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

- (void)setName:(NSString *)name{
    if (![_name isEqualToString:name]) {
        _name = [name copy];
        nameLabel.text = name;
        nameLabel.numberOfLines = 3;
        nameLabel.lineBreakMode = UILineBreakModeTailTruncation;
    }
}

- (void)setPrice:(NSString *)price{
    if (![_price isEqualToString:price]) {
        _price = [price copy];
        priceLabel.text = [NSString stringWithFormat:@"$%@", price];
    }
}

- (void)setQty:(NSString *)qty{
    if (![_qty isEqualToString:qty]) {
        _qty = [qty copy];
        qtyTextField.text = _qty;
    }
}

- (void)setImageData:(NSData *)imageData{
    if (![_imageData isEqual:imageData]) {
        _imageData = [imageData copy];
        [productImageView setImage:[UIImage imageWithData:_imageData]];
        productImageView.contentMode = UIViewContentModeScaleAspectFit;
    }
}

- (IBAction)deleteButtonClicked:(id)sender {
    [self.delegate removeProductFromCart:self.productID];
}

@end
